package controllers

import (
	"github.com/astaxie/beego"
)

//注解路由示例

type CMSController struct {
	beego.Controller
}

//用户如果没有进行注册，那么就会通过反射来执行对应的函数
func (c *CMSController) URLMapping() {
	c.Mapping("kill", c.KillOne)
	c.Mapping("save", c.SaveAll)
}

// 注意正则匹配问题 name必需有
// @router /kill/:name [get]
func (this *CMSController) KillOne() {
	name := this.Ctx.Input.Param(":name")
	this.Ctx.WriteString("<h1>kill "+name+"</h1>")
}

// @router /save/:name [get]
func (this *CMSController) SaveAll() {
	name := this.Ctx.Input.Param(":name")
	this.Ctx.WriteString("<h1>save "+name+"</h1>")
}
